package fr.aprr.geoloc.server.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import at.dormancy.JpaDormancy;
import fr.aprr.geoloc.shared.domain.FlotteVehiculeId;
import fr.aprr.geoloc.shared.domain.Onglets;

public class OngletsDao {

	@PersistenceContext
    private EntityManager entityManager;
	
	@Autowired
	JpaDormancy dormancy;
	
	@Transactional
	@SuppressWarnings("unchecked")
	public List<Onglets> getAllOnglets(){
		List<Onglets> listOnglets = entityManager.createQuery("from Onglets").getResultList();
		return dormancy.clone(listOnglets);
	}
	
	public Onglets getOnglet(Integer id){
		Onglets onglet = entityManager.find(Onglets.class, id);
		 return dormancy.clone(onglet);
	}
	
	public List<FlotteVehiculeId> getVehiculesByOnglet(String nom){
		List<FlotteVehiculeId> listVehicules = entityManager.createQuery("Select from FlotteVehiculeId").getResultList();
		return null;
	}
	
}
